package team.seekers.hula.course.course.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import team.seekers.hula.auth.service.MindUtils;
import team.seekers.hula.common.annotation.ApiResponseBody;
import team.seekers.hula.common.entity.PageResult;
import team.seekers.hula.course.course.entity.dto.CourseListReqDTO;
import team.seekers.hula.course.course.entity.vo.CourseInfoVO;
import team.seekers.hula.course.course.entity.vo.CourseListVO;
import team.seekers.hula.course.course.entity.vo.CourseProgressListVO;
import team.seekers.hula.course.course.service.CourseService;
import team.seekers.hula.course.structure.chapter.entity.dto.ChapterQueryListDTO;

import javax.annotation.Resource;
import java.util.List;


@Slf4j
@Controller
@ApiResponseBody
@RequestMapping("/course")
public class CourseController {

    @Resource
    private CourseService courseService;

    /**
     * 知桨分页查询
     */
    @GetMapping("/page")
    public PageResult<CourseListVO> page(CourseListReqDTO req) {
        return courseService.page(req);
    }

    /**
     * 知桨分页查询
     */
    @GetMapping("/page-progress")
    public PageResult<CourseProgressListVO> pageMine(CourseListReqDTO req) {
        req.setUserId(MindUtils.getUserId());
        return courseService.pageMine(req);
    }

    /**
     * 知桨按照id查询
     */
    @GetMapping("/list-by-ids")
    public List<CourseListVO> listByIds(@RequestParam List<String> courseIds) {
        return courseService.listByIds(courseIds);
    }

    /**
     *
     * 查询推荐知桨列表
     */
    @GetMapping("/list/push")
    public List<CourseListVO> listPush() {
        return courseService.listPush();
    }

    /**
     *
     * 查询常驻知桨列表
     */
    @GetMapping("/list/fixed")
    public List<CourseListVO> listFixed() {
        return courseService.listFixed();
    }



    /**
     * 查看知桨详情
     */
    @GetMapping("/info")
    public CourseInfoVO getCourseInfo(@RequestParam String courseId) {
        return courseService.getCourseInfo(courseId);
    }

    /**
     * 查询课程目录（未购买时的简介目录）
     */
    @GetMapping("/getSimpleCourseDirs")
    public List<ChapterQueryListDTO> getSimpleCourseDirs(@RequestParam String courseId) {
        return courseService.getSimpleCourseDirs(courseId);
    }

    /**
     * 查询课程目录（已购买的目录详情）
     */
    @GetMapping("/getDetailCourseDirs")
    public List<ChapterQueryListDTO> getDetailCourseDirs(@RequestParam String courseId) {
        return courseService.getDetailCourseDirs(courseId, MindUtils.getUserId());
    }
}
